package com.sakura.util.reflection;/**
 * Created by apple on 2019/8/14.
 */

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author jixd
 * @Description
 * @Date 2019/8/14 2:41 PM
 * @Version 1.0
 **/
public class TestBP {

    public String DS1(String json){
        System.out.println("method:DS1,param:"+json);
        return "2";
    }

    public String DS2(String json){
        System.out.println("method:DS2,param:"+json);
        return "3";
    }

    public String DS3(String json){
        System.out.println("method:DS3,param:"+json);
        return "4";
    }

    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException, InstantiationException {

        Class clazz = Class.forName("com.sakura.util.reflection.TestBP");
        Object object = clazz.newInstance();
        Method method1 = clazz.getDeclaredMethod("DS1", String.class);
        Method method2 = clazz.getDeclaredMethod("DS2", String.class);
        Method method3 = clazz.getDeclaredMethod("DS3", String.class);


        Object obj1 = method1.invoke(object, "1");
        Object obj2 = method2.invoke(object, String.valueOf(obj1));
        Object obj3 = method3.invoke(object, String.valueOf(obj2));

        //如果需要DS任意组合，必须要求DS的入参与返回值都为json
    }
}
